#-- coding:UTF-8 --

import requests
import json
import requests
from bs4 import BeautifulSoup

#爬数据

url1 = "https://www.qqorw.cn/mrzb/"
day = str(412)
url2 = '.html'
url = url1 + day + url2
url = url.replace(" ","")

# 定制消息头
headers = {
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36'
}
# 发送带消息头的请求
res = requests.get(url, headers=headers)
# 创建 BeautifulSoup 对象，解析响应的文本内容
soup = BeautifulSoup(res.text, 'html.parser')
book_name_tags = soup.select('div.content p')

for i in range(4,len(book_name_tags)-1):
    text = book_name_tags[i].text

#print(book_name_tags[5].text)




# 发送文本消息
def send_text(webhook, content, mentioned_list=None, mentioned_mobile_list=None):
    header = {
                "Content-Type": "application/json",
                "Charset": "UTF-8"
                }
    data ={

        "msgtype": "text",
        "text": {
            "content": content
            ,"mentioned_list":mentioned_list
            ,"mentioned_mobile_list":mentioned_mobile_list
        }
    }
    data = json.dumps(data)
    info = requests.post(url=webhook, data=data, headers=header)
webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=d181171e-862c-41bb-8a35-731de2bf484f"


send_text(webhook, content=book_name_tags[4].text)